package config

import (
	"time"
	"io/ioutil"
	"encoding/json"

	"github.com/name5566/leaf/log"
)

var (
// gate conf
	PENDING_WRITE_NUM = 2000
	MAX_MSG_LEN uint32 = 4096
	HTTP_TIMEOUT = 10 * time.Second
	LEN_MSG_LEN = 4
	LITTLE_ENDIAN = false

// skeleton conf
	GO_LEN = 10000
	TIMER_DISPATCHER_LEN = 10000
	CHAN_RPC_LEN = 10000

// login conf
	MIN_ACCOUNT_SIZE = 4    // 账号和密码的最大和最小长度(字节)
	MAX_ACCOUNT_SIZE = 32
	MIN_PASSWORD_SIZE = 4
	MAX_PASSWORD_SIZE = 32

// db conf
	DB_NAME = "poker_game"


// game conf
	INIT_TOTAL_MONEY int64 = 10000    // 玩家初始金钱
)

var Server struct {
	LogLevel     string
	LogPath      string
	WSAddr       string
	TCPAddr      string
	MaxConnNum   int
	DBMaxConnNum int
	DBUrl        string
}

func init() {
	data, err := ioutil.ReadFile("cfg/server.json")
	if err != nil {
		log.Fatal("%v", err)
	}
	err = json.Unmarshal(data, &Server)
	if err != nil {
		log.Fatal("%v", err)
	}
}
